﻿using Spider.Analyse;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;
using Spider.Rules;
using Common.Library.DownLoads;

namespace Spider.HTMLAnalyse.英语学习资料HTML解析
{
    public class tingclassDownLoad页面解析 : AnalyseBase, IAnalyse
    {
        public override List<T> GetListData<T>(HtmlDocument doc, IRule rule, object o = null)
        {
            List<T> listEntity = new List<T>();
            HtmlNode res = doc.DocumentNode.SelectSingleNode(rule.RuleXPathString());
            if (res != null)
            {
                var list = res.SelectNodes(@"a");//选择标签数组
                foreach (var a in list)
                {
                    if (a.InnerText == "返回在线学习")
                    {
                        continue;
                    }
                    //下载地址
                    DownLoadHelper.DownloadFile(a.OuterHtml.GetHref(), (string)o);
                }
            }


            //Tuple<URLListDTO, 新概念英语DemoEntity> tuple = new Tuple<URLListDTO, 新概念英语DemoEntity>(null, null);
            return listEntity;
        }
    }
}
